<template>
	<view class="pages">
		<my-header bgColor="bg-gradual-blue" :isBack="true" >
			<block slot="backText">返回</block>
			<block slot="content">我的分享</block>
		</my-header>
        <view class="goods_list col">
            <view class="goods " v-for="(item,index) in goods_list" :key="index">
                <view class="info row" @click="go(item.id)">
                    <image class="main_img" :src="item.main_img" mode="" />
                    <view class="main">
                        <view class="title">{{item.title}}</view>
                        <view class="price">原价：{{item.old_price}}</view>
                        <view class="price">预估返利：{{item.discount_price}}</view>
                        <!-- <view class="open" @click="this.flg=this.flg==index?-1:index">{{flg==index?"收起":"展开"}}</view> -->
                    </view>
                </view>
                <!-- <view class="opt" v-if="flg==index">
                    <view class="price">预估价格：{{item.old_price}}</view>
                    <view class="price">{{item.price}}</view>
                    <view class="price">{{item.discount_price}}</view>
                    <view class="price">{{item.share_url}}</view>
                </view> -->
            </view>

        </view>
        <!-- <view class="bottom"></view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
                
                flg:-2,
                goods_list:[]
			}
		},
		onLoad(options) {
           this.initData()
		},
		methods: {
            async initData(state=0){
                this.flg=state
				const openid=await uni.$get_openId()
                const res=await uni.$request({
                    state
                },"api/jd/get_goods_list")
                if (res.code==200) {
                    this.goods_list=res.data.goods_list
                } else{
                    uni.$err(res.msg)
                }
                console.log(res.data);
            },
            copy(data){
                uni.setClipboardData({
                    data,
                    success: function () {
                        console.log('success');
                    }
                });
            },
            go(id){
                uni.navigateTo({
                     url:"/pages/detail/detail?id="+id
                });
            }
		}
	}
</script>

<style lang="scss">
	@import "./index";
</style>